public class Solution {
        public static boolean isUpper(char ch){
            if(ch >= 'A' && ch <= 'Z'){
                return true;
            }
            return false;
        }
        public static String toLowerCase(String s) {
            StringBuffer sb = new StringBuffer();
            for(int i = 0;i < s.length();i++){
                char ch = s.charAt(i);
                if(isUpper(ch)){
                    sb.append((char) (ch+32));
                }else{
                    sb.append(ch);
                }
            }
            return sb.toString();

        }

    /**
     * 统计单词数量
     * @param s
     * @return
     */
    public static int countSegments(String s){
        if (s.length() == 0){
            return 0;
        }
        String[] ret = s.split(" ");
        System.out.println(ret.length);
        int count = 0;
        for (String s1:
             ret) {
            if (s1.length() != 0){
                count++;
            }
            
        }
        return count;
    }

    public static void main(String[] args) {
        int ret = Solution.countSegments("Hello, ,,,,,,        my name is John");
        System.out.println(ret);
        String s1 = toLowerCase("Tom");
        System.out.println(s1);


    }
}
